<?php
namespace app\bankcard\controller;

use tp5_lib\api\controller\ApiBaseController;
use tp5_lib\bankcard\model\BankcardModel;

class ApiController extends ApiBaseController
{
    public function bind()
    {
        $user=$this->checkLogin();
        $data=input();
        $data["user_id"]=$user["id"];
        $data["time"]=time();
        $model=new BankcardModel();
        if(!$model->check($data["card_id"])){
            $this->error("请输入正确的银行卡号");
        }
        if(!$model->db()->strict(false)->insert($data)){
            $this->error($model->getError());
        }
        $this->success();
    }
    public function getList()
    {
        $user=$this->checkLogin();
        $model=new BankcardModel();
        $list=$model->db()->where("user_id",$user["id"])->order("time desc")->select();
        $this->result($list,1);
    }
}
